class JDS{
    V = '2.0'
    W = parseInt($(window).width())
    J = "        __\n       /\\ \\\n  __   \\_\\ \\    ____\n /\\ \\  /'_  \\  /',__\\\n \\ \\ \\/\\ \\ \\ \\/\\__, `\\\n _\\ \\ \\ \\___,_\\/\\____/\n/\\ \\_\\ \\/__,_ /\\/___/\n\\ \\____/\n \\/___/";
    opt = {}

    constructor(opt = {}){
        // 实例化立刻实行
        // console.log(`${this.J} V:${this.V}`);
        alert(`${this.J} V:${this.V}`);

        // 参数初始化
        this.opt = Object.assign({
            angaAnimaSpeed: 600,
            angaAnimaMoreY: 0,
            angaAnimaLoadOn: true,
            animateOn: false,
            wowOn: false,
            skrollrOn: false,
            tilePC: null,
            tileSP: null
        }, opt )

        // 需要格式化的参数
        this.opt.angaAnimaSpeed = parseInt(this.opt.angaAnimaSpeed);
        this.opt.angaAnimaMoreY = parseInt(this.opt.angaAnimaMoreY);
        
        console.log(this.opt);

        // 实例化后要实行的内容
        this.init();
    }
    
    // 默认加载 3.3.1 可以自定义加载
    plus(fun,src='https://code.jquery.com/jquery-3.3.1.min.js'){
        jQuery.getScript(src, () => {
            const jQuery_3_3_1 = $.noConflict(true);
            (($) => {
                if(fun){
                    fun($);
                }
            })(jQuery_3_3_1)
        });
    }

    // 初始化默认启动项目
    init(){
        // 隐藏元素无法获取高度 所以先实行
        this.tileRun();

        // 以下库加载
        this.animate();
        this.wow();
        this.skrollr();
        // 以上库加载

        // 以下都有高度内容
        this.photoThumbnail();
        this.slides();
        this.tabBox();
        this.swiper();
        this.multiCheck();
        this.singleCheck();
        this.coponSwitch();
        this.searchRight();
        this.searchLight();
        this.megaMenu();
        this.mapList();
        this.smartMenu();
        this.macy();
        // 以上都有高度内容

        this.angaAnima();
        this.imgOver();
        this.baguetteBox();
        this.colorBox();
        this.switchMenu();
        window.onload = () => {
            // 对高度有精确要求的内容放入 initOnload 内
            this.initOnload();
            // skrollr 插件要求必须 onload 后初始化
            if(this.opt.skrollrOn){
                console.log('jdsSkrollr init');
                let jdsSkrollr = skrollr.init();
            }
            
        }
    }

    initOnload(){
        console.log('=========================== init onload');
        this.angaAnimaLoad();
        this.showFix();// 初始化就运行所以放入 onload 内
        this.alwaysFix();// 必须放在 onload 内不然会错位
        this.triggerClick();// 比如点击锚点需要高度都加载好才能正确定走位
        this.searchSp();// 检索框大挪移

        this.angaLoad();// 网址里设置参数主要适用于美乳跳转
    }

    tileTime = null
    tileAll(funPC,funSP){
        console.log('tileAll run !!!!!!!!!!!!');
        $(window).resize(() => {
            this.W = $(window).width();
        });
        if (this.W > 720) {
            if(funPC){
                funPC();
                console.log('tilePC');
            }
        } else {
            if(funSP){
                funSP();
                console.log('tileSP');
            }
        };
        $(window).resize(() => {
            if (this.tileTime !== false) {
                clearTimeout(this.tileTime);
            };
            this.tileTime = setTimeout(() => {
                // this.tileAll(funPC,funSP);
                // this.tileRun();
            }, 200);
        });
    }

    tileRun(){
        this.tileAll(this.opt.tilePC,this.opt.tileSP);
    }

    angaAnima(){
        $('#widewrapper a[href^=#]').not('#search-box a,a.jdsPagetop,a.jdsColorBoxHtml').Plugin_AngaAnima({
            animaSpeed:this.opt.angaAnimaSpeed,
            moreY:this.opt.angaAnimaMoreY
        });
        $('#widewrapper a.jdsPagetop').Plugin_AngaAnima({
            animaSpeed:this.opt.angaAnimaSpeed,
            moreY: 0
        });
    }

    angaLoad() {
        let getAngaLoad = '#'+ this.getUrlParam('anga');
        if(!$(getAngaLoad).length){
            return 
        }

        console.log('angaLoad run');

        let root = this;
        let angaGO = parseInt($(getAngaLoad).offset().top);
        $('html, body').not(':animated').animate({
                scrollTop: angaGO - root.opt.angaAnimaMoreY
            },
            root.opt.angaAnimaSpeed, 'swing',
            function () {
                //maybe need somting
            }
        );
    }
    
    angaAnimaLoad(){
        if(this.opt.angaAnimaLoadOn){
            $('body').Plugin_AngaLoad({
                speeder:this.opt.angaAnimaSpeed,
                moreY:this.opt.angaAnimaMoreY
            });
        }
    }

    photoThumbnail(){
        if ($('.jdsPhotoThumbnail').length <= 0) {
            return;
        };
        console.log('photoThumbnail run');
        
        $('.jdsPhotoThumbnail').each(function () {
            let this_jdsPhotoThumbnail = $(this);
            let this_hover = $(this).attr('hover');
            let handleClick = true;

            $(this_jdsPhotoThumbnail).find('.photoMore > div').hide();
            $(this_jdsPhotoThumbnail).find('.photoMore > div').eq(0).show();

            if (this_hover == 'true' && $(window).width() > 720) {
                $(this_jdsPhotoThumbnail).find('.thumPhotos img').each(function (i) {
                    $(this).hover(function () {
                        let ImgSrc = $(this).attr('src');
                        let ImgAlt = $(this).attr('alt');
                        let $mainPhoto = this_jdsPhotoThumbnail.find('img.mainPhoto');

                        $mainPhoto.attr({
                            src: ImgSrc,
                            alt: ImgAlt
                        });
                        $mainPhoto.hide();
                        $mainPhoto.fadeIn(0);

                        $(this_jdsPhotoThumbnail).find('.photoMore > div').hide();
                        $(this_jdsPhotoThumbnail).find('.photoMore > div').eq(i).fadeIn(0);

                        return false;
                    });
                    $(this).click(function () {
                        return false;
                    });
                });
            } else {
                $(this_jdsPhotoThumbnail).find('.thumPhotos img').each(function (i) {
                    $(this).click(function () {
                        if(handleClick){
                            handleClick = false;
                            let ImgSrc = $(this).attr('src');
                            let ImgAlt = $(this).attr('alt');
                            let $mainPhoto = this_jdsPhotoThumbnail.find('img.mainPhoto');

                            $mainPhoto.attr({
                                src: ImgSrc,
                                alt: ImgAlt
                            });

                            $mainPhoto.hide();
                            $mainPhoto.fadeIn(300,function(){
                                handleClick = true;
                            });

                            $(this_jdsPhotoThumbnail).find('.photoMore > div').hide();
                            $(this_jdsPhotoThumbnail).find('.photoMore > div').eq(i).fadeIn(300);
                        }

                        return false;
                    });
                });
            };
        });
    }

    getAttrSet(obj,attr,def,id,num) {
        let ojbAttr = $(obj).attr(attr);
        if(ojbAttr){
            if(id == true){
                ojbAttr = '#'+ojbAttr;
            };
            if(num == true){
                ojbAttr = parseInt(ojbAttr);
            };
            return ojbAttr;
        }else{
            return def;
        };
    }

    getUrlParam(name) {
        var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]);
        return null;
    }

    slides(){
        if ($('.jdsSlides').length <= 0) {
            return;
        };
        console.log('slides run');
        
        $('.jdsSlides').Plugin_LoadJS({
            about: 'responsiveslides.min.js',
            url: ['https://img.travel.rakuten.co.jp/special/smap/js/responsiveslides.min.js'],
            successDo: () => {
                let root = this;
                $('.jdsSlides').each(function (i) {
                    $(this).addClass('jdsSlides' + (i + 1));
                    $('.jdsSlides' + (i + 1)).responsiveSlides({
                        auto: root.getAttrSet(this,'auto',1,'',true),
                        timeout: root.getAttrSet(this,'timeout',4000,'',true),
                        pager: root.getAttrSet(this,'pager',false),
                        nav: root.getAttrSet(this,'nav',false),
                        manualControls: root.getAttrSet(this,'manualControls','',true)
                    });
                });
            }
        });
    }

    showFix(){
        if ($('.jdsShowFix').length <= 0) {
            return;
        };
        console.log('showFix run');
        let root = this;
        $('.jdsShowFix').each(function (i) {
            $(this).addClass('jdsShowFix' + (i + 1));
            $('.jdsShowFix' + (i + 1)).Plugin_ShowFix({
                fixY: '#' + $(this).attr('fixY'),
                showOnly: root.getAttrSet(this,'showOnly',false,true),
                top:$(this).attr('top')
            });
        });
    }

    alwaysFix(){
        if ($('.jdsAlwaysFix').length <= 0) {
            return;
        };
        console.log('alwaysFix run');
        let root = this;
        $('.jdsAlwaysFix').each(function (i) {
            if ($(this).attr('menu') == 'true') {
                $(this).wrapAll('<div style="height:' + $(this).height() + 'px"></div>');
            }
            $(this).addClass('jdsAlwaysFix' + (i + 1));
            $('.jdsAlwaysFix' + (i + 1)).Plugin_AlwaysFix({
                moreY: root.getAttrSet(this,'moreY',0,'',true)
            });
        });
    }

    coponSwitch(){
        if ($('.jdsCoponSwitch').length <= 0 && $('.cp__trigger').length <= 0) {
            return;
        };
        console.log('coponSwitch run');
        let root = this;
        $('.jdsCoponSwitch').each(function (i) {
            $(this).addClass('jdsCoponSwitch' + (i + 1));
            $('.jdsCoponSwitch' + (i + 1)).Plugin_CoponSwitch({
                speed: root.getAttrSet($(this),'speed','fast','',true)
            },root);
        });
    }

    tabBox(){
        if ($('.jdsTab').length <= 0) {
            return;
        };
        console.log('tabBox run');
        let root = this;
        $('.jdsTab').each(function (i) {
            let this_jdsTab = $(this);
            let this_sessionStorage = 'jdsTab' + i;// sessionStorage 在 IE 下看必须在服务器端看 本地看时报错的
            this_jdsTab.addClass('jdsTab' + i);
            
            let jdsTabMain = $(this_jdsTab).find('.jdsTabMain');
            let jdsTabNav_li = $(this_jdsTab).find('.jdsTabNav li');
            let jdsTabNavDown_li = $(this_jdsTab).find('.jdsTabNavDown li');
            let fadeSpeed = root.getAttrSet(this_jdsTab,'fadeSpeed',0,'',true);
            let show_eq = root.getAttrSet(this_jdsTab,'show',1,'',true) - 1;
            let downAnimate = root.getAttrSet(this_jdsTab,'downAnimate',true);
            let sessionOn = root.getAttrSet(this_jdsTab,'sessionOn',true);
    
            $(jdsTabNav_li).each(function (i) {
                $(this).click(function () {
                    $(jdsTabNav_li).removeClass('active');
                    $(jdsTabNav_li).eq(i).addClass('active');
                    sessionStorage.setItem(this_sessionStorage,i);
    
                    $(jdsTabMain).fadeOut(0);
                    $(jdsTabMain).eq(i).fadeIn(fadeSpeed, function () {
                        //
                    });
    
                    $(jdsTabNavDown_li).removeClass('active');
                    $(jdsTabNavDown_li).eq(i).addClass('active');
                });
            });
    
            $(jdsTabNavDown_li).each(function (i) {
                $(this).click(function () {
                    $(jdsTabNav_li).removeClass('active');
                    $(jdsTabNav_li).eq(i).addClass('active');
                    sessionStorage.setItem(this_sessionStorage,i);
    
                    $(jdsTabMain).fadeOut(0);
                    $(jdsTabMain).eq(i).fadeIn(fadeSpeed, function () {
                        if (downAnimate != 'false') {
                            setTimeout(function () {
                                $('html, body').not(':animated').animate({
                                        scrollTop: $(this_jdsTab).offset().top
                                    },
                                    600, 'swing');
                            }, 600);
                        }
                    });
    
                    $(jdsTabNavDown_li).removeClass('active');
                    $(jdsTabNavDown_li).eq(i).addClass('active');
                });
            });
    
            
            if(parseInt(sessionStorage.getItem(this_sessionStorage))+1 && sessionOn == true){
                $(jdsTabNav_li).eq(parseInt(sessionStorage.getItem(this_sessionStorage))).trigger('click');
            }else{
                $(jdsTabNav_li).eq(show_eq).trigger('click');
            }
        });
    }

    triggerClick(){
        if ($('.jdsTriggerClick').length <= 0) {
            return;
        };
        $('.jdsTriggerClick').each(function () {
            $(this).trigger('click');
        });
    }

    swiper(){
        if ($('.jdsSwiper').length <= 0) {
            return;
        };
        console.log('swiper run');
        $('<link>').attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: 'https://img.travel.rakuten.co.jp/special/supersale/201706/css/swiper.min.css'
        }).appendTo('head');
        $('.jdsSwiper').Plugin_LoadJS({
            about: 'swiper.min.js',
            url: ['https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.4.2/js/swiper.min.js'],
            successDo: () => {
                let root = this;
                $('.jdsSwiper').each(function (i) {
                    var mySwiper = 'mySwiper' + (i + 1);
                    var mySwiperClass = 'jdsSwiper' + (i + 1);
                    $(this).addClass(mySwiperClass);
                    mySwiperClass = '.' + 'jdsSwiper' + (i + 1);
    
                    var this_swiperSetup = root.getAttrSet(this,'swiperSetup','');
                    this_swiperSetup = $.parseJSON(this_swiperSetup.replace(/'/g, '"'));
                    var mySwiper = new Swiper($(mySwiperClass), this_swiperSetup);
                });
            }
        });
    }

    multiCheck(){
        if ($('.jdsMultiCheck').length <= 0) {
            return;
        };
        console.log('multiCheck run');
        $('.jQ-mc').each(function () {
            let this_jQ_mc = $(this);
            let this_jQ_mc_allBtn = $(this_jQ_mc).find('.multi-check li a').not('.allBtn');
            let this_mc_act = '.multi-check li a.active';
            $(this_jQ_mc_allBtn).each(function (i) {
                $(this).click(function () {
                    $(this_jQ_mc).find('.block').hide();
                    $(this_jQ_mc).find('.multi-check .allBtn').removeClass('active');
                    $(this).toggleClass('active');
                    let this_type = $(this).attr('title');
                    showNeed(this_jQ_mc);
                    showAll(this_jQ_mc);
                });
            });

            $(this_jQ_mc).find('.multi-check .allBtn').click(function () {
                $(this).toggleClass('active');
                $(this_jQ_mc_allBtn).removeClass('active');
                showAll2B(this_jQ_mc);
            });

            function showAll(this_jQ_mc) {
                let activeL = $(this_jQ_mc).find(this_mc_act).length;
                if (activeL == '0') {
                    $(this_jQ_mc).find('.block').show();
                }
            };

            function showAll2B(this_jQ_mc) {
                $(this_jQ_mc).find('.block').show();
            };

            function showNeed(this_jQ_mc) {
                if ($(this_jQ_mc).find(this_mc_act).length == 0) {
                    $(this_jQ_mc).find('.block').show();
                } else {
                    $(this_jQ_mc).find('.block').hide();
                    let num = $(this_jQ_mc).find(this_mc_act).length;
                    $(this_jQ_mc).find('.block').attr('class', 'block');
                    for (i = 0; i < num; i++) {
                        let this_id = $(this_jQ_mc).find(this_mc_act).eq(i).attr('title');
                        $(this_jQ_mc).find('.block').each(function (c) {
                            if ($(this).find('p.icoBtns span').hasClass(this_id)) {
                                $(this).addClass('needYou' + i);
                            };
                        });
                    };

                    $(this_jQ_mc).find('.block').each(function (q) {
                        let this_class = $(this).attr('class');
                        if ($(this).find('p.icoBtns span').length >= num) { //==
                            let len = (this_class.split('needYou')).length - 1;
                            if (len == num) {
                                $(this).show();
                            };
                        };
                    });
                };
            };
        });
    }

    singleCheck(){
        if ($('.jdsSingleCheck').length <= 0) {
            return;
        };
        console.log('jdsSingleCheck run');
        $('.jQ-sc').each(function () {
            let this_jQ_sc = $(this);
            let this_jQ_sc_allBtn = $(this_jQ_sc).find('.single-check li a').not('.allBtn');
            $(this_jQ_sc_allBtn).each(function (i) {
                $(this).click(function () {
                    $(this_jQ_sc).find('.block').hide();
                    $(this_jQ_sc).find('.single-check li a').removeClass('active');
                    $(this).toggleClass('active');
                    let this_type = $(this).attr('title');
                    showNeed2(this_jQ_sc);
                    showAll2(this_jQ_sc);
                });
            });

            $(this_jQ_sc).find('.single-check .allBtn').click(function () {
                $(this).toggleClass('active');
                $(this_jQ_sc_allBtn).removeClass('active');
                showAll22(this_jQ_sc);
            });

            function showAll2(this_jQ_sc) {
                let activeL = $(this_jQ_sc).find('.single-check li a.active').length;
                if (activeL == '0') {
                    $(this_jQ_sc).find('.block').show();
                }
            };

            function showAll22(this_jQ_sc) {
                $(this_jQ_sc).find('.block').show();
            };

            function showNeed2(this_jQ_sc) {
                if ($(this_jQ_sc).find('.single-check  li a.active').length == 0) {
                    $(this_jQ_sc).find('.block').show();
                } else {
                    $(this_jQ_sc).find('.block').hide();
                    let num = $(this_jQ_sc).find('.single-check  li a.active').length;
                    $(this_jQ_sc).find('.block').attr('class', 'block');
                    for (i = 0; i < num; i++) {
                        let this_id = $(this_jQ_sc).find('.single-check  li a.active').eq(i).attr('title');
                        $(this_jQ_sc).find('.block').each(function (c) {
                            if ($(this).find('p.icoBtns span').hasClass(this_id)) {
                                $(this).addClass('needYou' + i);
                            };
                        });
                    };

                    $(this_jQ_sc).find('.block').each(function (q) {
                        let this_class = $(this).attr('class');
                        if ($(this).find('p.icoBtns span').length >= num) { //==
                            let len = (this_class.split('needYou')).length - 1;
                            if (len == num) {
                                $(this).show();
                            };
                        };
                    });
                };
            };
        });
    }

    searchRight(){
        if ($('.jdsSearchRight').length <= 0) {
            return;
        };console.log('searchRight run');
        
        $('.jdsSearchRight').each(function (i) {
            let this_searchRight = $(this);

            $(this_searchRight).find('.thisBtn').css({
                'position': 'fixed',
                'top': '50%',
                'right': '0'
            });
            $(this_searchRight).find('.thisBox').css({
                'position': 'fixed',
                'top': '0',
                'right': '-100%',
                'width': '100%'
            });
            $(this_searchRight).find('#search-box').css({
                'margin': '0 auto'
            });

            $(this_searchRight).find('.thisBtn').click(function () {
                $(this_searchRight).find('.thisBox').animate({
                    'marginRight': '100%'
                }, 'swing');
                $(this).hide();
            });
            $(this_searchRight).find('.thisClose').click(function () {
                $(this_searchRight).find('.thisBox').animate({
                    'marginRight': '0%'
                }, 'swing');
                $(this_searchRight).find('.thisBtn').show();
            });
        });
    }

    searchLight(){
        if ($('.jdsSearchLight').length <= 0) {
            return;
        };
        console.log('searchLight run');
        $('.jdsSearchLight').each(function (i) {
            let this_searchRight = $(this);

            $(this_searchRight).find('.thisBox').css({
                'display': 'none',
                'position': 'fixed',
                'top': '0',
                'left': '0',
                'width': '100%'
            });
            $(this_searchRight).find('#search-box').css({
                'margin': '0 auto'
            });

            $(this_searchRight).find('.thisBtn').click(function () {
                $(this_searchRight).find('.thisBox').fadeIn('swing');
            });
            $(this_searchRight).find('.thisClose').click(function () {
                $(this_searchRight).find('.thisBox').fadeOut('swing');
            });
        });
    }

    searchSp(){
        if ($('.jdsSearchSp').length <= 0 || this.W > 720) {
            return;
        };
        console.log('searchSp run');
        
        let searchBox = $('#search-box');
        $('.jdsSearchSp').append(searchBox);
        $('.jdsSearch #search-box').hide();
    }

    imgOver(){
        if ($('img.jdsImgOver').length <= 0) {
            return;
        };
        console.log('imgOver run');

        let aPreLoad = new Array();
        let sTempSrc;
        let aImages = document.getElementsByTagName('img');

        for (let i = 0; i < aImages.length; i++) {
            if (aImages[i].className == 'jdsImgOver') {
                let src = aImages[i].getAttribute('src');
                let ftype = src.substring(src.lastIndexOf('.'), src.length);
                let hsrc = src.replace(ftype, '_o' + ftype);

                aImages[i].setAttribute('hsrc', hsrc);

                aPreLoad[i] = new Image();
                aPreLoad[i].src = hsrc;

                aImages[i].onmouseover = function () {
                    sTempSrc = this.getAttribute('src');
                    this.setAttribute('src', this.getAttribute('hsrc'));
                };

                aImages[i].onmouseout = function () {
                    if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o' + ftype, ftype);
                    this.setAttribute('src', sTempSrc);
                };
            };
        };
    }

    megaMenu(){
        if ($('.jdsMegaMenu.megamenu').length <= 0) {
            return;
        };
        console.log('megaMenu run');
        $('<link>').attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: 'https://img.travel.rakuten.co.jp/special/xmas/2016/css/jquery.megamenu.css'
        }).appendTo('head');
        $('.jdsMegaMenu').Plugin_LoadJS({
            about: 'jquery.megamenu.js http://www.geektantra.com/2010/05/jquery-megamenu-2/',
            url: ['https://img.travel.rakuten.co.jp/special/xmas/2016/js/jquery.megamenu.js'],
            successDo: () => {
                let root = this;
                $('.jdsMegaMenu').each(function (i) {
                    $(this).addClass('jdsMegaMenu' + (i + 1)).hide();
                    var this_megamenuSetup = root.getAttrSet(this,'megamenuSetup','');
                    this_megamenuSetup = $.parseJSON(this_megamenuSetup.replace(/'/g, '"'));
                    $('.jdsMegaMenu' + (i + 1)).megamenu(
                        this_megamenuSetup
                    );
                });
            }
        });
    }

    mapList(){
        if ($('.jdsMapList').length <= 0) {
            return;
        };
        console.log('mapList run');
        let root = this;
        $('.jdsMapList').each(function() {
            let self = $(this);
            let this_MapListMain = self.find('.jdsMapListMain');
            let this_MapListMain_dl = this_MapListMain.find('dl');
            let this_MapListMap = self.find('.jdsMapListMap img');
            this_MapListMap.hide();
            this_MapListMap.eq(0).show();
            this_MapListMain_dl.find('dt').next().hide();
            this_MapListMain_dl.each(function(i) {
                if(root.W > 720){
                    $(this).hover(function() {
                        $(this).find('dt').next().show();
                        this_MapListMap.hide();
                        this_MapListMap.eq(i+1).show();
                    }, function() {
                        $(this).find('dt').next().hide();
                    });
                }else{
                    $(this).find('dt').addClass('jdsCoponSwitch');
                };
            });
        });
    }

    smartMenu(){
        if ($('.jdsSmartMenu').length <= 0) {
            return;
        };
        console.log('smartMenu run');

        $('<link>').attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: 'https://vadikom.github.io/smartmenus/src/css/sm-core-css.css'
        }).appendTo('head');

        $('.jdsSmartMenu').Plugin_LoadJS({
            about: 'jquery.smartmenus.js https://www.smartmenus.org/docs/',
            url: ['https://img.travel.rakuten.co.jp/special/xmas/2016/js/jquery.smartmenus.js'],
            successDo: function () {
                $('.jdsSmartMenu').each(function (i) {
                    $(this).addClass('jdsSmartMenu' + (i + 1));
                    $('.jdsSmartMenu' + (i + 1)).smartmenus();

                    $(('.jdsSmartMenu' + (i + 1)) + ' li a.has-submenu').each(function (i) {
                        $(this).click(function () {
                            $(this).next('ul').slideToggle(200).toggleClass('jb');
                            if ($(this).next('ul').hasClass('jb')) {
                                $(this).find('.sub-arrow').html('-');
                            } else {
                                $(this).find('.sub-arrow').html('+');
                            };
                            return false;
                        });
                    });
                });
            }
        });
    }

    animate(){
        if (!this.opt.animateOn) {
            return;
        };
        console.log('animate onload');

        $('<link>').attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: 'https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css'
        }).appendTo('head');

        $(".animated[jdsAnimatedH]").each(function(){
            let _this = $(this);
            _this.hover(function(){
                _this.addClass(_this.attr('jdsAnimatedH'));
            },function(){

                _this.removeClass(_this.attr('jdsAnimatedH'));
            });
        });
    }

    wow(){
        if (!this.opt.animateOn || !this.opt.wowOn) {
            return;
        };
        console.log('wow onload');

        $('body').Plugin_LoadJS({
            about: 'wow.min.js https://github.com/matthieua/WOW',
            url: ['https://img.travel.rakuten.co.jp/kaigai_package/select/pic/js/wow.min.js'],
            successDo: function () {
                new WOW().init();
            }
        });
    }

    baguetteBox(){
        if ($('.jdsBaguetteBox').length <= 0) {
            return;
        };
        console.log('baguetteBox run');

        $('<link>').attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: 'https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.8.2/baguetteBox.min.css'
        }).appendTo('head');

        $('.jdsBaguetteBox').Plugin_LoadJS({
            about: 'baguetteBox.min.js https://github.com/feimosi/baguetteBox.js',
            url: ['https://feimosi.github.io/baguetteBox.js/js/baguetteBox.js'],//之前的引用版本有 error 错误
            successDo: () => {
                baguetteBox.run('.jdsBaguetteBox');
            }
        });
    }

    colorBox(){
        if ($('a.jdsColorBoxImg').length <= 0 && $('a.jdsColorBoxUrl').length <= 0 && $('a.jdsColorBoxHtml').length <= 0) {
            return;
        };
        console.log('colorBox run');
        

        $('<link>').attr({
            rel: 'stylesheet',
            type: 'text/css',
            href: 'https://travel.rakuten.co.jp/movement/kouchi/201603/css/colorbox.css'
        }).appendTo('head');

        var jdsColorBoxImgArr = [];

        $('body').Plugin_LoadJS({
            about: 'jquery.colorbox.js http://www.jacklmoore.com/colorbox/',
            url: ['https://travel.rakuten.co.jp/movement/kouchi/201603/js/jquery.colorbox.js'],
            successDo: () => {
                let root = this;
                //only one
                $('.jdsColorBoxImg:not([rel])').each(function (i) {
                    $(this).addClass('jdsColorBoxImg' + (i + 1));
                    $('.' + 'jdsColorBoxImg' + (i + 1)).colorbox();
                });
                //group
                $('.jdsColorBoxImg[rel]').each(function (i) {
                    var this_group = $(this).attr('rel');
                    if ($.inArray(this_group, jdsColorBoxImgArr) == -1) {
                        jdsColorBoxImgArr.push(this_group);
                    };
                });
                for (var i = 0; i < jdsColorBoxImgArr.length; i++) {
                    $('.' + jdsColorBoxImgArr[i]).colorbox({
                        rel: jdsColorBoxImgArr[i]
                    });
                };
                //url
                $('.jdsColorBoxUrl').each(function (i) {
                    $(this).addClass('jdsColorBoxUrl' + (i + 1));
                    $('.' + 'jdsColorBoxUrl' + (i + 1)).colorbox({
                        iframe: true,
                        width: root.getAttrSet(this,'thisWidth','80%'),
                        height: root.getAttrSet(this,'thisHeight','80%')
                    });
                });
                //html box
                $('.jdsColorBoxHtml').each(function (i) {
                    $(this).addClass('jdsColorBoxHtml' + (i + 1));
                    $('.' + 'jdsColorBoxHtml' + (i + 1)).colorbox({
                        inline: true,
                        width: root.getAttrSet(this,'thisWidth','80%'),
                        height: root.getAttrSet(this,'thisHeight','80%')
                    });
                });
            }
        });
    }

    macy(){
        if ($('.jdsMacy').length <= 0) {
            return;
        };
        console.log('macy run');

        $('.jdsMacy').Plugin_LoadJS({
            about: 'macy.js https://macyjs.com/',
            url: ['http://macyjs.com/assets/js/macy.min.js'],
            successDo: () => {
                let root = this;
                $('.jdsMacy').each(function (i) {
                    var masonry = 'jdsMacy' + (i + 1);
                    var myMacyClass = '.' + 'jdsMacy' + (i + 1);
                    $(this).addClass('jdsMacy' + (i + 1));

                    var masonry = new Macy({
                        container: myMacyClass,
                        trueOrder: false,
                        waitForImages: false,
                        useOwnImageLoader: false,
                        debug: true,
                        mobileFirst: true,
                        columns: root.getAttrSet(this,'columns',4,'',true),
                        margin: root.getAttrSet(this,'margin',24,'',true),
                        breakAt: {
                            720: root.getAttrSet(this,'sp',2,'',true)
                        }
                    });
                });
            }
        });
    }

    skrollr(){
        if (!this.opt.skrollrOn) {
            return;
        };
        console.log('skrollr onload');

        $('body').Plugin_LoadJS({
            about: 'skrollr.min.js https://github.com/Prinzhorn/skrollr',
            url: ['https://prinzhorn.github.io/skrollr/dist/skrollr.min.js'],
            successDo: function () {
                //
            }
        });
    }

    switchMenu(){
        if ($('.jdsSwitchMenu').length <= 0) {
            return;
        };console.log('switchMenu run');
        $('.jdsSwitchMenu').each(function(){
            var _this = this;
            $(_this).click(function(){
                $(_this).toggleClass('active');
            });
            // 锚点也关闭
            $(_this).find('a').click(function(){
                $(_this).toggleClass('active');
            });
        });

        // 点击空白处关闭
        $(document).click(function(e) { 
            var  pop = $('.jdsSwitchMenu,.jdsSwitchMenu ul');  
            if(!pop.is(e.target) && pop.has(e.target).length === 0) {
                $('.jdsSwitchMenu').addClass('active');
            }  
        });
    }

    



    


































    
}

// ==============================================================================================================================
(function ($) { //tile.js
    $.fn.tile = function (columns) {
        let tiles, max, c, h, last = this.length - 1,
            s;
        if (!columns) columns = this.length;
        this.each(function () {
            s = this.style;
            if (s.removeProperty) s.removeProperty('height');
            if (s.removeAttribute) s.removeAttribute('height');
        });
        return this.each(function (i) {
            c = i % columns;
            if (c == 0) tiles = [];
            tiles[c] = $(this);
            h = tiles[c].height();
            if (c == 0 || h > max) max = h;
            if (i == last || c == columns - 1)
                $.each(tiles, function () {
                    this.height(max);
                });
        });
    };
})(jQuery);
// ==============================================================================================================================
(function ($) { //AngaAnima
    let AngaAnima = function (ele, opt) {
        this.$ele = ele;
        this.defaults = {
            animaSpeed: 600,
            moreY: 0,
            moreDo: function () {}
        };
        this.options = $.extend({}, this.defaults, opt);
    };
    AngaAnima.prototype = {
        AngaAnimaMe: function () {
            let self = this,
                angaID,
                angaGO;
            self.$ele.click(function () {
                angaID = $(this).attr('href');
                if ($(angaID).length > 0) {
                    angaGO = parseInt($(angaID).offset().top); // tile.js must do it!
                    $('html, body').not(':animated').animate(
                        {
                            scrollTop: angaGO - self.options.moreY
                        },
                        self.options.animaSpeed, 'swing',
                        function () {
                            //maybe need somting
                        }
                    );
                    if (angaID == "#search-box") {
                        $("#searchTitle").addClass("close");
                        $("#searchTitle").removeClass("open");
                        $("#search-box-body").slideDown();
                    }
                    return false;
                }
            });
        }
    };
    $.fn.Plugin_AngaAnima = function (options) {
        let Plugin_AngaAnima_Run = new AngaAnima(this, options);
        Plugin_AngaAnima_Run.AngaAnimaMe();
    };
})(jQuery);
// ==============================================================================================================================
(function ($) { //AngaLoad
    let AngaLoad = function (ele,opt) {
        this.angaGO = 0;
        this.defaults = {
            speeder: 600,
            moreY: 0
        };
        this.options = $.extend({}, this.defaults, opt);
    };
    AngaLoad.prototype = {
        angaLoadCore: function () {
            let hash = location.hash;
            let self = this;

            if ($(hash).length > 0) {
                // $('html, body').scrollTop(0);
                this.angaLoadCoreGo(hash);
                $('html, body').not(':animated').animate({
                        scrollTop: this.angaGO - self.options.moreY
                    },
                    this.options.speeder, 'swing');
            }
        },
        angaLoadCoreGo: function (hash) {
            this.angaGO = $(hash).offset().top - this.angaGO;
            return this.angaGO;
        }
    };
    $.fn.Plugin_AngaLoad = function (options) {
        let Plugin_AngaLoad_Run = new AngaLoad(this, options);
        Plugin_AngaLoad_Run.angaLoadCore();
    };
})(jQuery);
// ==============================================================================================================================
(function ($) { //load JS file
    let LoadJS = function (ele, opt) {
        this.ele = ele,
            this.defaults = {
                about: '',
                url: [],
                successDo: function () {}
            },
            this.options = $.extend({}, this.defaults, opt)
    };
    LoadJS.prototype = {
        LoadJSDo: function () {
            let self = this;
            if ($(this.ele.selector).length && this.options.url.length) {
                for (let item in this.options.url) {
                    $.getScript(this.options.url[item], function () {
                        self.LoadJSDoMore();
                    });
                }
            }
        },
        LoadJSDoMore: function () {
            this.options.successDo();
        }
    };
    $.fn.Plugin_LoadJS = function (url) {
        let Plugin_LoadJDSJS_RUN = new LoadJS(this, url);
        Plugin_LoadJDSJS_RUN.LoadJSDo();
    };
})(jQuery);
// ==============================================================================================================================
(function ($) { //ShowFix
    let ShowFix = function (ele, opt) {
        this.$ele = ele,
            this.timer = null,
            this._rt = '.rt-header',
            this.defaults = {
                fixY: 'body',
                showSpeed: 300,
                showOnly: false,
                top:false,
                moreDO: function () {}
            },
            this.options = $.extend({}, this.defaults, opt)
    };
    ShowFix.prototype = {
        scrollMe: function (ojb) {
            if ($(this.options.fixY).length > 0) {
                
                // 对象位置每次滚动都会实时获取，不会存在onload问题
                this._fixY = $(this.options.fixY).offset().top;
                if (this.options.top){// 设置 top 浏览器底部就出发
                    
                    if ($(document).scrollTop() + $(window).height() > this._fixY) {
                        this.$ele.addClass('active');
                        if ($(this.$ele).is(':hidden')) {
                            this.$ele.fadeIn(this.options.showSpeed);
                        } else {
                            this.$ele.fadeIn(0);
                        }
                    } else {
                        this.$ele.removeClass('active');
                        if (!$(this.$ele).is(':hidden')) {
                            this.$ele.fadeOut(this.options.showSpeed);
                        } else {
                            this.$ele.fadeOut(0);
                        }
                    };
                }else{// 默认到浏览器顶部触发
                    if ($(document).scrollTop() > this._fixY) {
                        this.$ele.addClass('active');
                        if ($(this.$ele).is(':hidden')) {
                            this.$ele.fadeIn(this.options.showSpeed);
                        } else {
                            this.$ele.fadeIn(0);
                        }
                    } else {
                        this.$ele.removeClass('active');
                        if (!$(this.$ele).is(':hidden')) {
                            this.$ele.fadeOut(this.options.showSpeed);
                        } else {
                            this.$ele.fadeOut(0);
                        }
                    };
                }
            }else{
                throw new Error('jdsShowFix.fixY - 参数错误');
            };

            if ($(this.options.showOnly).length > 0) {
                // 对象位置每次滚动都会实时获取，不会存在onload问题
                if ($(document).scrollTop() + $(window).height() > $(this.options.showOnly).offset().top + $(this.options.showOnly).height()) {
                    this.$ele.addClass('active2');
                    this.$ele.css({
                        'position': 'absolute'
                    });
                } else {
                    this.$ele.removeClass('active2');
                    this.$ele.css({
                        'position': 'fixed'
                    });
                }
            };
        },
        windowScroll: function () {
            this.$ele.hide();
            let self = this;
            self.scrollMe(this.$ele);
            let windowsW = $(window).width();
            // 默认就先实行一次
            self.scrollMe(self.$ele);
            $(window).scroll(function () {
                self.scrollMe(self.$ele);
            });
        }
    };
    $.fn.Plugin_ShowFix = function (options) {
        let Plugin_ShowFix_Run = new ShowFix(this, options);
        Plugin_ShowFix_Run.windowScroll();
        return this;
    };
})(jQuery);
// ==============================================================================================================================
(function ($) { //AlwaysFix
    let AlwaysFix = function (ele, opt) {
        this.$ele = ele,
            this._rt = '.rt-header',
            this.timer = null,
            this.defaults = {
                moreY: 0
            },
            this.options = $.extend({}, this.defaults, opt)
    };
    AlwaysFix.prototype = {
        scrollMe: function () {
            this._ele = $(this.$ele).offset().top;
            this._defTtop = $(this.$ele).css('top');
            let self = this;
            self.scrollBase();
            $(window).scroll(function () {
                if (self.timer) {
                    clearTimeout(self.timer);
                };
                self.timer = setTimeout(function () {
                    self.scrollBase();
                }, 0);
            });
        },
        scrollBase: function () {
            let self = this;
            if ($(document).scrollTop() > self._ele - self.options.moreY) {
                self.$ele.addClass('active').css({
                    'position': 'fixed',
                    'top': self.options.moreY
                });
            } else {
                // 对象位置每次滚动都会实时获取，不会存在onload问题
                this._ele = $(this.$ele).offset().top;
                self.$ele.removeClass('active').css({
                    'position': '',
                    'top': self._defTtop
                });
            }
        }
    };
    $.fn.Plugin_AlwaysFix = function (options) {
        let Plugin_AlwaysFix_Run = new AlwaysFix(this, options);
        Plugin_AlwaysFix_Run.scrollMe();
    };
})(jQuery);
// ==============================================================================================================================
(function ($) { //CoponSwitch
    let CoponSwitch = function (ele,opt,root) {
        this.$ele = ele,
            this.defaults = {
                speed: 'fast'
            },
            this.options = $.extend({}, this.defaults, opt),
            this.root = root
    };
    CoponSwitch.prototype = {
        coponSwitchCore: function () {
            let self = this;
            $(this.$ele).each(function (i) {
                let speed = self.options.speed;
                if ($(this).attr('class').indexOf('active-submenu') < 0) {
                    $(this).next().hide();
                };
                $(this).click(function () {
                    if ($(this).next().is(':hidden')) {
                        $(this).addClass('active-submenu');
                        $(this).next().slideDown(speed,function(){
                            //
                        });
                    } else {
                        $(this).removeClass('active-submenu');
                        $(this).next().slideUp(speed,function(){
                            //
                        });
                    }
                });
            });
        }
    };
    $.fn.Plugin_CoponSwitch = function (options,root) {
        let Plugin_CoponSwitch_Run = new CoponSwitch(this, options,root);
        Plugin_CoponSwitch_Run.coponSwitchCore();
    };
})(jQuery);
// ==============================================================================================================================
